home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Just Call Me Internet
/
Just Call Me Internet.iso
/
prog
/
atari
/
m2
/
cat3src
/
cat
/
mtpaths.i
< prev
next >
Wrap
Text File
|
1997-10-26
|
6KB
|
187 lines
IMPLEMENTATION MODULE MTPaths;
FROM SYSTEM IMPORT ADR;
FROM Characters IMPORT CR, LF;
FROM CatFiles IMPORT SetPath, GetPath;
FROM Void IMPORT v;
IMPORT MTE;
IMPORT MagicAES;
IMPORT MagicDOS;
IMPORT MagicStrings;
IMPORT mtAppl;
IMPORT mtCommand;
IMPORT mtDir;
IMPORT mtAlerts;
IMPORT mtTextfiles;
IMPORT CatGlobal;
(*
VAR ARCPath,
EditorPath,
MessagePath,
ImportPath,
ExportPath,
DataPath,
TerminalPath : ARRAY[0..160] OF CHAR;
ARCName,
EditorName,
archiveName,
TerminalName : ARRAY[0..14] OF CHAR;
enarcStr,
dearcStr,
TerminalCmd : ARRAY[0..80] OF CHAR;
Gruppe : ARRAY[0..7] OF ARRAY[0..16] OF CHAR;
ReadPos : CARDINAL;
*)
CONST catinf = 'cat.inf'+0C;
VAR slash : ARRAY[0..1] OF CHAR;
PROCEDURE ReadString(CATINF : mtTextfiles.TEXTFILE; VAR str : ARRAY OF CHAR):BOOLEAN;
BEGIN
IF mtTextfiles.EndofText(CATINF) THEN RETURN FALSE; END;
mtTextfiles.ReadLine(CATINF, str);
mtTextfiles.ReadLn(CATINF);
RETURN TRUE;
END ReadString;
PROCEDURE ReadInf(VAR path, name : ARRAY OF CHAR; noCommand, showError: BOOLEAN):BOOLEAN;
VAR z : CARDINAL;
CATINF : mtTextfiles.TEXTFILE;
currentPath,
sARCPath,
sEditorPath,
sMessagePath,
sImportPath,
sExportPath,
sDataPath,
sTerminalPath : ARRAY[0..255] OF CHAR;
sARCName,
sarchiveName,
sTerminalName : ARRAY[0..40] OF CHAR;
senarcStr,
sdearcStr,
sTerminalCmd : ARRAY[0..255] OF CHAR;
openName : ARRAY[0..12] OF CHAR;
scrap : ARRAY[0..255] OF CHAR;
infname : ARRAY[0..79] OF CHAR;
PROCEDURE err();
BEGIN
IF showError THEN v.int := mtAlerts.Alert(1, MTE.noInf); END;
END err;
PROCEDURE err2();
BEGIN
IF showError THEN v.int := mtAlerts.Alert(1, MTE.illegalInf); END;
END err2;
BEGIN
(* Wenn ein Dateiname bergeben wird, dann soll der geladen werden.
* Wenn auch in der Kommandozeile ein Dateiname steht und noCommand FALSE
* ist, dann soll der Dateiname aus der Kommandozeile genommen werden
*)
IF ~noCommand & (mtCommand.ParamCount() > 0)
THEN
mtCommand.ParamString(1, scrap);
z := MagicStrings.Length(scrap);
WHILE (z > 0) & (scrap[z-1] < ' ') DO scrap[z-1] := 0C; DEC(z) END;
(* Steuerzeichen am Ende vernichten *)
IF (scrap[0] # '-') & (scrap[0] # 0C) THEN
mtDir.SplitPath(scrap, path, openName, name);
IF path[0] = 0C
THEN
(* Applikations-Pfad nehmen *)
CatGlobal.ApplPath (path);
END;
ELSE
MagicStrings.Assign (name, openName);
END;
ELSIF (path[0] = 0C)
THEN
(* Kein Pfad bergeben, Default nehmen *)
MagicStrings.Assign (catinf, openName);
(* Pfad der Applikation nehmen *)
CatGlobal.ApplPath(path);
ELSE
MagicStrings.Assign(name, openName);
END;
IF openName[0] = ''
THEN
MagicStrings.Assign (catinf, openName);
END;
MagicStrings.Assign(path, scrap);
MagicStrings.Append(openName, scrap);
IF ~mtTextfiles.OpenTextfile(scrap, mtTextfiles.READ, 512, CATINF) THEN
(* Wenn nicht auf aktuellem Pfad, dann ber ShelFind probieren *)
MagicStrings.Assign (openName, scrap);
MagicAES.ShelFind(scrap);
IF ~mtTextfiles.OpenTextfile(scrap, mtTextfiles.READ, 512, CATINF) THEN
IF ~MagicStrings.Equal (openName, catinf) & ~noCommand
THEN
MagicStrings.Assign (catinf, openName);
MagicStrings.Assign(path, scrap);
MagicStrings.Append(openName, scrap);
IF ~mtTextfiles.OpenTextfile(scrap, mtTextfiles.READ, 512, CATINF) THEN
err(); RETURN FALSE
END;
ELSE
err(); RETURN FALSE
END;
END;
END;
IF ~ReadString(CATINF, sARCPath) OR ~ReadString(CATINF, sARCName) OR
~ReadString(CATINF, senarcStr) OR ~ReadString(CATINF, sdearcStr) OR
~ReadString(CATINF, sarchiveName) OR ~ReadString(CATINF, sEditorPath)
THEN
mtTextfiles.CloseTextfile(CATINF);
err2();
RETURN FALSE
END;
IF ~ReadString(CATINF, sEditorPath) OR ~ReadString(CATINF, sMessagePath) OR
~ReadString(CATINF, sImportPath) OR ~ReadString(CATINF, sExportPath) OR
~ReadString(CATINF, sDataPath) OR ~ReadString(CATINF, sTerminalPath) THEN
mtTextfiles.CloseTextfile(CATINF);
err2();
RETURN FALSE
END;
IF ~ReadString(CATINF, sTerminalName) OR ~ReadString(CATINF, sTerminalCmd) THEN
mtTextfiles.CloseTextfile(CATINF);
err2();
RETURN FALSE
END;
mtTextfiles.CloseTextfile(CATINF);
GetPath (currentPath);
IF SetPath(sMessagePath) & SetPath(sImportPath) &
SetPath(sExportPath) & SetPath(sDataPath) THEN
MagicStrings.Assign( sARCPath, ARCPath );
MagicStrings.Assign( sMessagePath, MessagePath );
MagicStrings.Assign( sImportPath, ImportPath );
MagicStrings.Assign( sExportPath, ExportPath );
MagicStrings.Assign( sDataPath, DataPath );
MagicStrings.Assign( sTerminalPath, TerminalPath );
MagicStrings.Assign( sARCName, ARCName );
MagicStrings.Assign( sarchiveName, archiveName );
MagicStrings.Assign( sTerminalName, TerminalName );
MagicStrings.Assign( senarcStr, enarcStr );
MagicStrings.Assign( sdearcStr, dearcStr );
MagicStrings.Assign( sTerminalCmd, TerminalCmd );
v.bool := SetPath (currentPath);
MagicStrings.Assign (scrap, lastInfName);
MagicStrings.Assign (path, CatGlobal.infPath);
MagicStrings.Assign (openName, CatGlobal.infName);
RETURN TRUE
ELSE
IF showError THEN v.int := mtAlerts.Alert(1, MTE.notAllPaths); END;
v.bool := SetPath (currentPath);
RETURN FALSE
END
END ReadInf;
END MTPaths.